package com.ruoyi.informfrontend.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.informfrontend.domain.Wenzhang;
import com.ruoyi.informfrontend.service.IWenzhangService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务案例Controller
 *
 * @author ruoyi
 * @date 2023-05-17
 */
@RestController
@RequestMapping("/wenzhang")
public class WenzhangController extends BaseController
{
    @Autowired
    private IWenzhangService wenzhangService;

    /**
     * 查询服务案例列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Wenzhang wenzhang)
    {
        startPage();
        List<Wenzhang> list = wenzhangService.selectWenzhangList(wenzhang);
        return getDataTable(list);
    }

    /**
     * 查询服务案例列表
     */
    @GetMapping("/app")
    public AjaxResult app(Wenzhang wenzhang)
    {
        startPage();
        List<Wenzhang> list = wenzhangService.selectWenzhangList(wenzhang);
        return success(list);
    }


    /**
     * 获取服务案例详细信息
     */
    @GetMapping(value = "/getOne")
    public AjaxResult getInfo(@RequestParam("id") Long id)
    {
        return success(wenzhangService.selectWenzhangById(id));
    }

    /**
     * 新增服务案例
     */
    @PostMapping
    public AjaxResult add(@RequestBody Wenzhang wenzhang)
    {
        return toAjax(wenzhangService.insertWenzhang(wenzhang));
    }

    /**
     * 修改服务案例
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Wenzhang wenzhang)
    {
        return toAjax(wenzhangService.updateWenzhang(wenzhang));
    }

    /**
     * 删除服务案例
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wenzhangService.deleteWenzhangByIds(ids));
    }
}
